import java.util.*;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;

public class DisplayUSMap extends Application {
    @Override
    public void start(Stage primaryStage) {
        City[] vertices =
                {
                        new City(75, 50, "Seattle"), new City(50, 210, "San Francisco"),
                        new City(75, 275, "Los Angeles"), new City(275, 175, "Denver"),
                        new City(400, 245, "Kansas City"), new City(450, 100, "Chicago"),
                        new City(700, 80, "Boston"), new City(675, 120, "New York"),
                        new City(575, 295, "Atlanta"), new City(600, 400, "Miami"),
                        new City(408, 325, "Dallas"), new City(450, 360, "Houston"),
                };
        int[][] edges =
                {
                        {0, 1}, {0, 3}, {0, 5},
                        {1, 0}, {1, 2}, {1, 3},
                        {2, 1}, {2, 3}, {2, 4}, {2, 10},
                        {3, 0}, {3, 1}, {3, 2}, {3, 4}, {3, 5},
                        {4, 2}, {4, 3}, {4, 5}, {4, 7}, {4, 8}, {4, 10},
                        {5, 0}, {5, 3}, {5, 4}, {5, 6}, {5, 7},
                        {6, 5}, {6, 7},
                        {7, 4}, {7, 5}, {7, 6}, {7, 8},
                        {8, 4}, {8, 7}, {8, 9}, {8, 10}, {8, 11},
                        {9, 8}, {9, 11},
                        {10, 2}, {10, 4}, {10, 8}, {10, 11},
                        {11, 8}, {11, 9}, {11, 10},
                };

        Graph<City> mapGraph = new UnweightedGraph<>(vertices, edges);

        Scene scene = new Scene(new GraphView(mapGraph), 750, 450);
        primaryStage.setTitle("DisplayUSMap");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    /**
     * 定义一个内部类：City
     * 属性：位置和名字
     */
    public static class City implements Displayable {
        private int x, y;
        private String name;

        public City(int x, int y, String name) {
            this.x = x;
            this.y = y;
            this.name = name;
        }

        @Override
        public int getX() {
            return x;
        }

        @Override
        public int getY() {
            return y;
        }

        @Override
        public String getName() {
            return name;
        }
    }
}